
cmake_minimum_required(VERSION 3.4.1)

# 库的名字
set(libname ffmpeg-android)

# c++ 编译参数
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
# jnilibs 的目录
set(jnilibs ${CMAKE_SOURCE_DIR}/../../../libs)
#头文件
include_directories(${CMAKE_SOURCE_DIR}/include
        ${CMAKE_SOURCE_DIR}/glm
        ${CMAKE_SOURCE_DIR}/utils
        ${CMAKE_SOURCE_DIR}/player
        ${CMAKE_SOURCE_DIR}/player/render
        ${CMAKE_SOURCE_DIR}/player/decoder
        ${CMAKE_SOURCE_DIR}/player/render/video
        ${CMAKE_SOURCE_DIR}/player/render/audio
        ${CMAKE_SOURCE_DIR}/player/decoder/video
        ${CMAKE_SOURCE_DIR}/player/decoder/audio
        )
# 链接到这个目录下
link_directories(${jnilibs}/${CMAKE_ANDROID_ARCH_ABI})
# 源文件
file(GLOB src-files ${CMAKE_SOURCE_DIR}/*.cpp
        ${CMAKE_SOURCE_DIR}/utils/*.cpp
        ${CMAKE_SOURCE_DIR}/player/*.cpp
        ${CMAKE_SOURCE_DIR}/player/render/*.cpp
        ${CMAKE_SOURCE_DIR}/player/decoder/*.cpp
        ${CMAKE_SOURCE_DIR}/player/render/video/*.cpp
        ${CMAKE_SOURCE_DIR}/player/render/audio/*.cpp
        ${CMAKE_SOURCE_DIR}/player/decoder/video/*cpp
        ${CMAKE_SOURCE_DIR}/player/decoder/audio/*cpp
        )

# 生成用动态库
add_library(
        ${libname}
        SHARED
        ${src-files})


set(third-libs
        avformat
        avcodec
        avutil
        avfilter
        swresample
        swscale)

set(native-libs
        android
        EGL
        GLESv3
        OpenSLES
        m
        z
        )
# 查找系统库
find_library(
        log-lib
        log)

# -Wl , --start-group
# -Wl, --end-group
#命令用来  忽略  依赖顺序的问题
#链接这些库文件
target_link_libraries(
        ${libname}
        ${log-lib}
        -Wl,--start-group
        ${third-libs}
        -Wl,--end-group
        ${native-libs}
)